package com.lmkj.ddapploginapitable.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lmkj.ddapploginapitable.generator.entity.AuthorizConf;
import com.lmkj.ddapploginapitable.generator.service.AuthorizConfService;
import com.lmkj.ddapploginapitable.util.JsonResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/autoriz-conf")
public class ApiAuthorizConfController {

    @Resource
    private AuthorizConfService authorizConfServiceImpl;

    @PostMapping("/find-one")
    public JsonResult findOne(@RequestParam("urlToken") String urlToken) {
        LambdaQueryWrapper<AuthorizConf> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AuthorizConf::getUrlToken, urlToken);
        AuthorizConf authorizConf = authorizConfServiceImpl.getOne(queryWrapper);
        if(authorizConf == null){
            return JsonResult.ok().setCode(404);
        }
        return JsonResult.ok(authorizConf);
    }

}
